/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you want to add, delete, or rename functions or slots, use
** Qt Designer to update this file, preserving your code.
**
** You should not define a constructor or destructor in this file.
** Instead, write your code in functions called init() and destroy().
** These will automatically be called by the form's constructor and
** destructor.
*****************************************************************************/

void
ListaWindow::init()
{
	this->listosa = new lista<QString>;
}

void
ListaWindow::destroy()
{
	delete this->listosa;
}

void ListaWindow::enableBtnPush()
{
	const QString
	vazia = "";

	if(  EditPush->text() != vazia)
	{
		BtnPush->setEnabled(true);
	}
	else
	{
		BtnPush->setEnabled(false);
	}
}


void ListaWindow::push()
{	
	this->listosa->push( EditPush->text() );
	
	EditPush->setText("");
	BtnPush->setEnabled(false);
	
	this->updatePop();
}


void ListaWindow::pop()
{
	this->listosa->pop();
	this->updatePop();
}


void ListaWindow::next()
{
	this->listosa->next();
	
	this->updatePop();
}


void ListaWindow::previous()
{
	this->listosa->previous();
	
	this->updatePop();
}


void ListaWindow::updatePop()
{
	if (! this->listosa->isEmpty() )
	{
		LabelShowContent->setText( this->listosa->getInfo() );
		BtnPop->setEnabled(true);
		
		if (this->listosa->isLast() == false)
			BtnPrevious->setEnabled(true);
		else
			BtnPrevious->setEnabled(false);
		
		if(this->listosa->isFirst() == false)
			BtnNext->setEnabled(true);
		else
			BtnNext->setEnabled(false);
	}
	else
	{
		LabelShowContent->setText( "Lista Vazia" );
		BtnPop->setEnabled(false);
		
		BtnNext->setEnabled(false);
		BtnPrevious->setEnabled(false);
	}
	
}

void ListaWindow::clear()
{
	this->listosa->clear();
			
	this->updatePop();
}
